//
//  UIAlertController+show.m
//  WeiNingProject
//
//  Created by tianjians on 2018/10/10.
//  Copyright © 2018年 卫宁数据. All rights reserved.
//

#import "UIAlertController+show.h"

@implementation UIAlertController (show)

+(void)showalertControllerShowTitle:(NSString *)title styele:(UIAlertControllerStyle)style presentVC:(UIViewController *)selfVC
{
    UIAlertController *alertAC = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleCancel) handler:nil];
    [alertAC addAction:action1];
    [selfVC presentViewController:alertAC animated:YES completion:nil];
}

+(void )showalertControllerShowTitle:(NSString *)title styele:(UIAlertControllerStyle)style presentVC:(UIViewController *)selfVC action:(void (^)(void))complateHandle
{
    UIAlertController *alertAC = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        complateHandle();
    }];
    [alertAC addAction:action1];
    [alertAC addAction:action2];
    [selfVC presentViewController:alertAC animated:YES completion:nil];
}


+(void)showalertControllerShowTitle:(NSString *)title styele:(UIAlertControllerStyle)style placeHolder:(NSString *)placeholder presentVC:(UIViewController *)selfVC action:(void (^)(NSString *))complateHandle
{
    UIAlertController *alertAC = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
    [alertAC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.placeholder = placeholder;
    }];
    
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        complateHandle(alertAC.textFields[0].text);
    }];
    [alertAC addAction:action1];
    [alertAC addAction:action2];
    [selfVC presentViewController:alertAC animated:YES completion:nil];
    
}
+(void )showalertControllerShowTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle sureButtonTitle:(NSString *)sureButtonTitle presentVC:(UIViewController *)selfVC action:(void (^)(void))complateHandle
{
    UIAlertController *alertAC = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:cancelButtonTitle style:(UIAlertActionStyleCancel) handler:nil];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:sureButtonTitle style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        complateHandle();
    }];
    [alertAC addAction:action1];
    [alertAC addAction:action2];
    [selfVC presentViewController:alertAC animated:YES completion:nil];
}

+(void)showalertControllerShowTitle:(NSString *)title styele:(UIAlertControllerStyle)style presentVC:(UIViewController *)selfVC sureAction:(void(^)(void))sureComloateHandle
{
    UIAlertController *alertAC = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        sureComloateHandle();
    }];
    [alertAC addAction:action2];
    [selfVC presentViewController:alertAC animated:YES completion:nil];
}



+(void )showalertControllerShowTitle:(NSString *)title sureAction:(NSString *)sureTitle cancelAction:(NSString *)cancelTitle styele:(UIAlertControllerStyle)style presentVC:(UIViewController *)selfVC action:(void (^)(void))complateHandle
{
    UIAlertController *alertAC = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:cancelTitle style:(UIAlertActionStyleCancel) handler:nil];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:sureTitle style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        complateHandle();
    }];
    [alertAC addAction:action1];
    [alertAC addAction:action2];
    [selfVC presentViewController:alertAC animated:YES completion:nil];
}




@end
